<!DOCTYPE html>
<!--
Copyright (c) 2013 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->

<link rel="import" href="/tracing/base/event_target.html">
<link rel="import" href="/tracing/base/utils.html">
<link rel="import" href="/tracing/core/test_utils.html">
<link rel="import" href="/tracing/extras/importer/trace_event_importer.html">
<link rel="import" href="/tracing/model/event_set.html">
<link rel="import" href="/tracing/model/model.html">
<link rel="import" href="/tracing/ui/analysis/analysis_view.html">
<link rel="import" href="/tracing/ui/base/deep_utils.html">
<link rel="import" href="/tracing/ui/brushing_state_controller.html">
<link rel="import" href="/tracing/ui/extras/chrome/cc/layer_tree_host_impl_view.html">
<link rel="import" href="/tracing/ui/extras/chrome/cc/raster_task_selection.html">
<link rel="import" href="/tracing/ui/extras/chrome/cc/raster_task_view.html">

<script src="/tracing/extras/chrome/cc/layer_tree_host_impl_test_data.js">
</script>

<script>
'use strict';

tr.b.unittest.testSuite(function() {
  function createSelection() {
    const m = tr.c.TestUtils.newModelWithEvents([g_catLTHIEvents]);
    const p = m.processes[1];
    const rasterTasks = p.threads[1].sliceGroup.slices.filter(function(slice) {
      return slice.title === 'RasterTask' || slice.title === 'AnalyzeTask';
    });

    const selection = new tr.model.EventSet();
    selection.model = m;

    selection.push(rasterTasks[0]);
    selection.push(rasterTasks[1]);
    return selection;
  }

  test('basic', function() {
    const selection = createSelection();
    const view = document.createElement('tr-ui-e-chrome-cc-raster-task-view');
    view.selection = selection;
    this.addHTMLOutput(view);
  });

  // See https://crbug.com/1143376.
  skipTest('analysisViewIntegration', function() {
    const selection = createSelection();

    const timelineView = {model: selection.model};
    const brushingStateController =
        new tr.c.BrushingStateController(timelineView);

    const analysisEl = document.createElement('tr-ui-a-analysis-view');
    analysisEl.brushingStateController = brushingStateController;
    brushingStateController.changeSelectionFromTimeline(selection);

    assert.isDefined(Polymer.dom(analysisEl).querySelector(
        'tr-ui-e-chrome-cc-raster-task-view'));

    const sv = tr.ui.b.findDeepElementMatching(
        analysisEl, 'tr-ui-a-multi-thread-slice-sub-view');
    assert.isTrue(sv.requiresTallView);
    this.addHTMLOutput(analysisEl);
  });
});
</script>
